class Cache {
  setItem(name, value) {
    localStorage.setItem(name, JSON.stringify(value))
  }

  getItem(name, defaultValue) {
    const val = localStorage.getItem(name)
    return val ? JSON.parse(val) : undefined
  }

  removeItem(name) {
    localStorage.removeItem(name)
  }
}

const cache = new Cache()